<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Http\Requests;
use App\Services\Product\ExcelService;
use Illuminate\Http\Request;

class ExcelController extends Controller{

    private $_excelService;

    public function __construct(ExcelService $excelService){
        $this->_excelService = $excelService;
    }

    public function upload(Request $request){

        $file = $request->file('file');

        if ($request->hasFile('file')) {
            // echo $file->isValid();
            $this->_excelService->upload($file);
        }

        return formatJsonResponse();
    }

    public function import(Request $request){

        $this->_excelService->readExcelFileByChunk();
        return formatJsonResponse();
    }

    public function getModelParams(){
        return formatJsonResponse($this->_excelService->getModelParams('ShengEJingDianPu'));
    }

}
